<?php
namespace Home\Controller;
use Think\Controller;
class ListsectorController extends Controller {
  // 后台登录页
    public function index(){
        if(isset($_SESSION['admin'])){
            $sector = D("sector");
            $sectorList = $sector->select();
            $this->assign('list',$sectorList); 
            $this->display();           
        }else{
             $url = 'http://localhost/person/index.php/Home/Index/index';
            header("location: $url");
        }
    }

     public function positionDelete($id){
        $position = D('postition');
        $data['state'] = 1;        
        //$success = $project->where("id='$id'")->delete();
        $success = $position->where("id='$id'")->delete($data);
        if($success){
            $result = array(
                'code'=> '0',
                'ext'=> 'success'
            );
            echo json_encode($result);
        }else {
            $result = array(
                'code'=> '1',
                'ext'=> 'fail'
            );
            echo json_encode($result);
        }
    }




     // 管理页面首页
    public function manage(){
        if(!isset($_SESSION['admin']) || !$_SESSION['admin']){
            $url = 'http://localhost/person/index.php/Home/Index';
            header("location: $url");
        }else{                    
            $this->display();
        }
    }

      //退出
    public function doLogout(){
        $_SESSION = array();
        if(isset($_COOKIE[session_name()])){
            setcookie(session_name(),'',time()-1,'/');
        }
        session_destroy();
        $this->redirect('Index/index');
    }
}